<template>
	<sw-form-frame v-model="visible" :title="formName" width="560" :type="formType" :loading="btnLoading" footer @submit="handleSubmitForm()">
		<el-form ref="form" :model="formData" :rules="formRules" label-width="80px" class="backup_form_wrapper">
			<el-form-item label="备份名称" prop="name">
				<el-input v-model="formData.name" placeholder="请输入备份名称"></el-input>
			</el-form-item>
			<el-form-item label="备份描述" prop="content">
				<el-input type="textarea" v-model="formData.content" placeholder="请输入备份描述"></el-input>
			</el-form-item>
		</el-form>
	</sw-form-frame>
</template>

<script>
import moment from 'moment';
import formMixins from '@/mixins/formMixins';
import { backupDetail, backupDatabase, updateBackup } from '@/api/system/tbSysBackup';
export default {
	mixins: [formMixins],
	data() {
		return {
			formName: '备份',
			formRules: {
				name: [{ required: true, message: '请输入备份名称', trigger: 'blur' }]
			}
		};
	},
	computed: {
		detailData() {
			return eval(backupDetail);
		},
		callFunction() {
			return eval(this.addOrEdit ? backupDatabase : updateBackup);
		}
	},
	methods: {
		formatFormParams() {
			if (this.addOrEdit) {
				let timeName = moment().format('YYYY-MM-DD_HH:mm:ss');
				this.$set(this.formData, 'name', `备份${timeName}`);
			}
		}
	}
};
</script>
